import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  server: {
    port: 3000,
    host: '0.0.0.0', // 允许局域网访问
    proxy: {

      '/wx_users': {
        target: 'http://127.0.0.1:8000',
        changeOrigin: true
      },
      '/GetLoginQrCodeNew': {
        target: 'http://127.0.0.1:8000',
        changeOrigin: true
      },
      '/ws': {
        target: 'http://127.0.0.1:8000',
        changeOrigin: true
      },
      '/socket.io': {
        target: 'http://127.0.0.1:8000',
        changeOrigin: true,
        ws: true
      },
      '/api/v1/rag': {

        target: 'http://192.168.1.111:1602', // 另一个服务运行在1602端口
        // target: 'http://host.docker.internal:6001',
        // target: 'http://127.0.0.1:1602', // 另一个服务运行在1602端口

        changeOrigin: true
      },
      '/api': {
        target: 'http://127.0.0.1:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})